package com.core.zyyz.amc.modules.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.core.common.annotation.Log;
import com.core.common.core.controller.BaseController;
import com.core.common.core.domain.AjaxResult;
import com.core.common.enums.BusinessType;
import com.core.zyyz.amc.modules.domain.AmcProjectNode;
import com.core.zyyz.amc.modules.service.AmcProjectNodeService;
import com.core.common.utils.poi.ExcelUtil;
import com.core.common.core.page.TableDataInfo;

/**
 * 节点配置Controller
 *
 * @author LiuFushun
 * @date 2024-11-20
 */
@RestController
@RequestMapping("/amc/projectNode")
public class AmcProjectNodeController extends BaseController
{
    @Autowired
    private AmcProjectNodeService amcProjectNodeService;

    /**
     * 查询节点配置列表
     */
    @PreAuthorize("@ss.hasPermi('amc:projectNode:list')")
    @GetMapping("/list")
    public TableDataInfo list(AmcProjectNode amcProjectNode)
    {
        startPage();
        List<AmcProjectNode> list = amcProjectNodeService.selectAmcProjectNodeList(amcProjectNode);
        return getDataTable(list);
    }


    /**
     * 获取节点配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('amc:projectNode:query')")
    @GetMapping(value = "/{nodeId}")
    public AjaxResult getInfo(@PathVariable("nodeId") String nodeId)
    {
        return success(amcProjectNodeService.selectAmcProjectNodeByNodeId(nodeId));
    }

    /**
     * 新增节点配置
     */
    @PreAuthorize("@ss.hasPermi('amc:projectNode:add')")
    @Log(title = "节点配置", businessType = BusinessType.INSERT)
    @PostMapping("/insertNode")
    public AjaxResult add(@RequestBody AmcProjectNode amcProjectNode)
    {
        return toAjax(amcProjectNodeService.insertAmcProjectNode(amcProjectNode));
    }

    /**
     * 修改节点配置
     */
    @PreAuthorize("@ss.hasPermi('amc:projectNode:edit')")
    @Log(title = "节点配置", businessType = BusinessType.UPDATE)
    @PostMapping("/updateNode")
    public AjaxResult edit(@RequestBody AmcProjectNode amcProjectNode)
    {
        return toAjax(amcProjectNodeService.updateAmcProjectNode(amcProjectNode));
    }

    /**
     * 删除节点配置
     */
    @PreAuthorize("@ss.hasPermi('amc:projectNode:remove')")
    @Log(title = "节点配置", businessType = BusinessType.DELETE)
    @DeleteMapping("/{nodeIds}")
    public AjaxResult remove(@PathVariable String[] nodeIds)
    {
        return toAjax(amcProjectNodeService.deleteAmcProjectNodeByNodeIds(nodeIds));
    }
}
